package com.example.testproject.activity.constraint

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.example.testproject.R
import kotlinx.android.synthetic.main.activity_barrier.*

/**
 *
 * @ClassName: BarrierActivity
 * @Author: 史大拿
 * @CreateDate: 8/16/22$ 2:07 PM$
 * TODO 约束布局中Barrier使用
 */
class BarrierActivity : AppCompatActivity() {

    private val randomList = arrayListOf(
        "短字符串1234",
        "短",
        "长字符串长字符串长字符串长字符串长字符串长字符串",
        "长字符串长字符串长字符串长字符串长字符串长字符串长字符串长字符串end",
        "中等字符串1",
        "中等字符串2",
        "中等字符串3",
        "超长字符串超长字符串超长字符串超长字符串超长字符串超长字符串超长字符串超长字符串超长字符串超长字符串超长字符串超长字符串超长字符串",
    )


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_barrier)

        btn.setOnClickListener {
            tv1.text = getRandomText()
            tv2.text = getRandomText()
        }
    }

    // 获取随机字符
   private fun getRandomText() = let {
        randomList[(0 until randomList.size).random()]
    }
}